/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package application;

import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.fxml.Initializable;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;

public class ProfileController implements Initializable {

	/**
	 * Initializes the controller class.
	 */

	@FXML
	private Label plan12;

	@FXML
	private Label plan1;

	@FXML
	private ComboBox<String> profileBox;

	@FXML
	private Label plan21;

	@FXML
	private TextArea profileView;

	@FXML
	private Label plan11;

	@FXML
	private Button createBtn;

	@FXML
	void showProfile(Event event) {
		List<DivePlan> profile = Main.userProfiles.get(profileBox.getValue());

		profileView.setText("");

		for (DivePlan plan : profile) {
			profileView.appendText(plan.toString() + "\n");
		}
	}

	@FXML
	void createProfile(Event event) {
		Main.gotoScene("Dive.fxml", createBtn, this);
	}

	@Override
	public void initialize(URL url, ResourceBundle rb) {
		if (Main.userProfiles.isEmpty()) {
			profileBox.setVisible(false);
			profileView.setText("No profiles exist.");
		} else {
			ObservableList list = FXCollections.observableArrayList();
			list.addAll(Main.userProfiles.keySet().toArray());
			profileBox.setItems(list);
		}

	}

}
